<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<xsl:template match="object[@type='user']" mode="ownerbar">
		<xsl:param name="avatarOff" />
		<xsl:param name="showName" />
		<xsl:param name="login" select="property[@name='login']/value" />
		<xsl:param name="rating" select="property[@name='rating']/value" />
		<xsl:param name="allowVote" select="@vote-allowed" />
		
		<div class="ownerbar">
			<div class="rating-wrapper">
				<xsl:apply-templates select="document(concat('xmodule://system/getVoted/', $rating, ';', $allowVote, ';', @type-id, ';', @id, ';2'))/data/response/vote" mode="user-vote" />
			</div>
			
			<xsl:if test="$avatarOff != 1">
				<div class="avatar">
					<img alt="{$login}">
						<xsl:attribute name="src">
							<xsl:if test="property[@name='avatar']/value = ''">
								<xsl:value-of select="concat ($baseURI, '/images/default-user-avatar.png')" />
							</xsl:if>
							<xsl:if test="property[@name='avatar']/value != ''">
								<xsl:value-of select="concat ($baseURI, '/thumb_50_50', property[@name='avatar']/value)" />
							</xsl:if>
						</xsl:attribute>
					</img>
					
					<i class="corner-mask-white-5 tl"></i>
					<i class="corner-mask-white-5 tr"></i>
					<i class="corner-mask-white-5 br"></i>
					<i class="corner-mask-white-5 bl"></i>
				</div>
			</xsl:if>
			
			<div class="header">
				<div class="controls">
					<xsl:if test="$userId != @id and $userGroup != 'guest'">
						<a href="#" id="friend_control" onclick="Friend.set({@id}); return false;">
							<xsl:if test="@friend = 1">
								<xsl:attribute name="title">Удалить из друзей</xsl:attribute>
								<xsl:attribute name="class">friend delete</xsl:attribute>
							</xsl:if>
							<xsl:if test="@friend = 0">
								<xsl:attribute name="title">Добавить в друзья</xsl:attribute>
								<xsl:attribute name="class">friend add</xsl:attribute>
							</xsl:if>
						</a>
					</xsl:if>
				</div>
				
				<div class="title">
					<a href="{$baseURI}/user/{$login}">
						<xsl:value-of select="$login" />
					</a>
				</div>
			</div>
		</div>
		
		<div class="tabs">
			<ul>
				<li>
					<xsl:if test="$module = 'users'">
						<xsl:attribute name="class">selected</xsl:attribute>
					</xsl:if>
					<a href="{$baseURI}/user/{$login}">Профиль</a>
					
					<i class="corner-mask-eee-5 tl"></i>
					<i class="corner-mask-eee-5 tr"></i>
					<i class="corner-mask-eee-5 br"></i>
					<i class="corner-mask-eee-5 bl"></i>
				</li>
				<li>
					<xsl:if test="$module = 'blogs'">
						<xsl:attribute name="class">selected</xsl:attribute>
					</xsl:if>
					<a href="{$baseURI}/blogs/user/{$login}">Блог</a>
					
					<i class="corner-mask-eee-5 tl"></i>
					<i class="corner-mask-eee-5 tr"></i>
					<i class="corner-mask-eee-5 br"></i>
					<i class="corner-mask-eee-5 bl"></i>
				</li>
				<li>
					<xsl:if test="$module = 'photos'">
						<xsl:attribute name="class">selected</xsl:attribute>
					</xsl:if>
					<a href="{$baseURI}/photos/user/{$login}">Фотографии</a>
					
					<i class="corner-mask-eee-5 tl"></i>
					<i class="corner-mask-eee-5 tr"></i>
					<i class="corner-mask-eee-5 br"></i>
					<i class="corner-mask-eee-5 bl"></i>
				</li>
				<li>
					<xsl:if test="$module = 'comments'">
						<xsl:attribute name="class">selected</xsl:attribute>
					</xsl:if>
					<a href="{$baseURI}/comments/user/{$login}">Комментарии</a>
					
					<i class="corner-mask-eee-5 tl"></i>
					<i class="corner-mask-eee-5 tr"></i>
					<i class="corner-mask-eee-5 br"></i>
					<i class="corner-mask-eee-5 bl"></i>
				</li>
				<li>
					<xsl:if test="$module = 'micro'">
						<xsl:attribute name="class">selected</xsl:attribute>
					</xsl:if>
					<a href="{$baseURI}/micro/user/{$login}">Микро</a>
					
					<i class="corner-mask-eee-5 tl"></i>
					<i class="corner-mask-eee-5 tr"></i>
					<i class="corner-mask-eee-5 br"></i>
					<i class="corner-mask-eee-5 bl"></i>
				</li>
			</ul>
		</div>
	</xsl:template>
	
	<!-- USER VOTE -->
	<xsl:template match="vote" mode="user-vote">
		<xsl:param name="objectId" select="object_id" />
		<xsl:param name="vote" select="mark" />
		<xsl:param name="allow" select="allow" />
		<xsl:param name="rating" select="rating" />
		<xsl:param name="format" select="format" />
		
		<div class="vote-rating corner" id="user_rating">
			<a class="minus" title="не нравится" href="#">
				<xsl:choose>
					<xsl:when test="$allow = '0' and $vote = ''">
						<xsl:attribute name="onclick">new Error ('Вы не можете проголосовать'); return false;</xsl:attribute>
						<xsl:attribute name="class">minus cant</xsl:attribute>
					</xsl:when>
					<xsl:when test="$allow = '0' and $vote != ''">
						<xsl:attribute name="onclick">new Error ('Повторное голосование запрещено'); return false;</xsl:attribute>
						<xsl:if test="$vote = '0'">
							<xsl:attribute name="class">minus voted</xsl:attribute>
						</xsl:if>
						<xsl:if test="$vote != '0'">
							<xsl:attribute name="class">minus cant</xsl:attribute>
						</xsl:if>
					</xsl:when>
					<xsl:otherwise>
						<xsl:attribute name="onclick">
							<xsl:value-of select="concat ('User.vote (', $objectId, ', 0); return false;')" />
						</xsl:attribute>
					</xsl:otherwise>
				</xsl:choose>
				
				<img src="{$baseURI}/images/post-vote-minus.png" alt="Минус" />
			</a>
			
			<div class="number">
				<xsl:if test="number ($rating) &gt; 0">
					<xsl:attribute name="class">number plus</xsl:attribute>
				</xsl:if>
				<xsl:if test="number ($rating) &lt; 0">
					<xsl:attribute name="class">number minus</xsl:attribute>
				</xsl:if>
				<xsl:value-of select="$format" />
			</div>
			
			<a class="plus" title="нравится" href="#">
				<xsl:choose>
					<xsl:when test="$allow = '0' and $vote = ''">
						<xsl:attribute name="onclick">new Error ('Вы не можете проголосовать'); return false;</xsl:attribute>
						<xsl:attribute name="class">plus cant</xsl:attribute>
					</xsl:when>
					<xsl:when test="$allow = '0' and $vote != ''">
						<xsl:attribute name="onclick">new Error ('Повторное голосование запрещено'); return false;</xsl:attribute>
						<xsl:if test="$vote = '1'">
							<xsl:attribute name="class">plus voted</xsl:attribute>
						</xsl:if>
						<xsl:if test="$vote != '1'">
							<xsl:attribute name="class">plus cant</xsl:attribute>
						</xsl:if>
					</xsl:when>
					<xsl:otherwise>
						<xsl:attribute name="onclick">
							<xsl:value-of select="concat ('User.vote (', $objectId, ', 1); return false;')" />
						</xsl:attribute>
					</xsl:otherwise>
				</xsl:choose>
				
				<img src="{$baseURI}/images/post-vote-plus.png" alt="Плюс" />
			</a>
			
			<i class="tl"></i>
			<i class="tr"></i>
			<i class="br"></i>
			<i class="bl"></i>
		</div>
	</xsl:template>

</xsl:stylesheet>